package day1102;

import java.util.ArrayList;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @program: qy158
 * @description:
 * @author: 闫克起2
 * @create: 2022-11-02 10:59
 **/
public class demo04 {
    public static void main(String[] args) {
        //修改功能加锁了  但是它的读取没有加锁
        CopyOnWriteArrayList<String> list=new CopyOnWriteArrayList();

        for(int i=1;i<=8;i++){
            final int a=i;
            new Thread(new Runnable() {
                @Override
                public void run() {
                         list.add(Thread.currentThread().getName()+"==="+a+"====");
                         System.out.println(list);
                }
            }).start();
        }



//        System.out.println(list);
    }
}
